/**
 * Created by DELL on 2018/9/17.
 */
var tools = {
  /*截取url参数。转化成obj形式*/
  getParams: function () {
    var url = decodeURI(window.location.href);
    var theRequest = {};
    var start = url.indexOf("?");
    // var start = url.lastIndexOf("?");// ios现在是两个问号
    if (start !== -1) {
      var str = url.substr(start + 1);
      var strs = str.split("&");
      for (var i = 0; i < strs.length; i++) {
        theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
      }
    }
    return theRequest;
  },
  is_wxBrowser: function () {
    return /micromessenger/.test(navigator.userAgent.toLowerCase());
  },
  is_iOS: function () {
    return /(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent);
  },
  is_android: function () {
    return /android/i.test(navigator.userAgent);
  },
  // 1000 -> 1k
  numToString: function (num) {
    var __zan = parseInt(num);
    if (__zan / 1000 >= 1) {
      __zan = (__zan / 1000).toFixed(1) + "k";
    }
    return __zan;
  }
};